import React, { Component } from 'react';
import {withRouter} from "react-router-dom"
import Header from "../components/all/header";
import Footer from "../components/all/footer";
import { Menu } from 'antd';
import { UserOutlined ,HighlightOutlined ,SnippetsOutlined ,HomeOutlined ,ShoppingOutlined ,CloseCircleOutlined ,BranchesOutlined ,SettingOutlined} from '@ant-design/icons';
import {Redirect, Route ,Switch} from "react-router-dom";
import allOrder from "./myself_er/all_order";
import allPay from "./myself_er/all_pay";
import noPay from "./myself_er/no_pay";
import noShouHuo from "./myself_er/no_shouhuo";
import wuliu from "./myself_er/wuliu"
import {SMyself} from "../styled/myself";
import confirm from 'antd/lib/modal/confirm';
import { message, Button, Space } from 'antd';
const { SubMenu } = Menu;
class Myself extends Component {
    constructor(props){
        super(props)
    }
    //二级路由跳转
    jumpRouter(router){
        this.props.history.push(router)
    }
    //退出登录
    tuichu(){
        let that = this;
        confirm({
            title: '确认退出？',
            content: '退出后信息将会保留',
            onOk() {
                sessionStorage.clear();
                message.success(' 退出成功！ ');
                that.jumpRouter("/login")
            },
            onCancel() {
            //   console.log('Cancel');
            },
        });
    }
    // 分享 
    weixin(router){
        window.location.href=router
    }
    // 是否是管理员？
    isyesAdmin(){
        if(sessionStorage.getItem("userIdcard") == 1){
            return (
                <Menu.Item key="6" icon={<SettingOutlined />}  onClick={this.jumpRouter.bind(this,"/admin")}>管理平台</Menu.Item>
            )
        }
    }
    render() {
        return (
            <div>
                <Header></Header>
                <SMyself>
                <div className="left">
                    <Menu onClick={this.handleClick} style={{ width: 256 }} defaultSelectedKeys={['3']} defaultOpenKeys={['sub1']} mode="inline">
                        <SubMenu key="sub1" icon={<UserOutlined />} title="个人中心">
                            <Menu.ItemGroup key="g1" title="我的">
                                {/* <Menu.Item key="1" icon={<HighlightOutlined />}  onClick={this.jumpRouter.bind(this,"/myself/")}>编辑地址 </Menu.Item> */}
                                <Menu.Item key="2" icon={<SnippetsOutlined />}  onClick={this.jumpRouter.bind(this,"/myself/allOrder")}>全部订单 </Menu.Item>
                                <Menu.Item key="3" icon={<SnippetsOutlined />}  onClick={this.jumpRouter.bind(this,"/myself/noPay")}>待付款 </Menu.Item>
                                <Menu.Item key="4" icon={<SnippetsOutlined />}  onClick={this.jumpRouter.bind(this,"/myself/allPay")}>待发货 </Menu.Item>
                                <Menu.Item key="5" icon={<SnippetsOutlined />}  onClick={this.jumpRouter.bind(this,"/myself/noShouHuo")}>待收货 </Menu.Item>
                                {this.isyesAdmin.bind(this)()}
                                {/* <Menu.Item key="6" icon={<SnippetsOutlined />}  onClick={this.jumpRouter.bind(this,"/admin")}>管理平台</Menu.Item> */}
                                <Menu.Item key="7" icon={<HomeOutlined />} onClick={this.jumpRouter.bind(this,"/index")}>回到首页 </Menu.Item>
                                <Menu.Item key="8" icon={<ShoppingOutlined />}  onClick={this.jumpRouter.bind(this,"/shoppingCar")}>购物袋 </Menu.Item>
                                <Menu.Item key="9" icon={<CloseCircleOutlined />}  onClick={this.tuichu.bind(this)}>退出登录 </Menu.Item>
                                <Menu.Item key="10" icon={<BranchesOutlined />}><a href="/https://wx.qq.com/"  target="_blank" rel="noopener noreferrer" >分享 </a> </Menu.Item>
                            </Menu.ItemGroup>
                        </SubMenu>
                    </Menu>
                </div>
                <div className="right">
                    <Switch>
                        <Route path="/myself/allOrder" component={allOrder} />
                        <Route path="/myself/allPay" component={allPay} />
                        <Route path="/myself/noPay" component={noPay} />
                        <Route path="/myself/noShouHuo" component={noShouHuo} />
                        <Route path="/myself/wuliu" component={wuliu} />
                        <Redirect from="/myself" to="/myself/noPay" />
                    </Switch>
                </div>
                </SMyself>
                <Footer></Footer>
            </div>
        )
    }
}
export default withRouter(Myself)